<template>
  <el-container>
    <el-header>
  <el-form :model="form" :inline="true">
    <el-form-item label="服务名称">
      <el-select v-model="form.serviceId" placeholder="活动区域">
        <el-option
          v-for="item in dicServices"
          :key="item.id"
          :label="item.name"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="提供者id" label-width="120">
      <el-select v-model="form.providerid" placeholder="请选择">
        <el-option
          v-for="item in dicProviders"
          :key="item.id"
          :label="item.name"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="运营商" label-width="120">
      <el-select v-model="form.operationId" placeholder="请选择">
        <el-option
          v-for="item in dicOperations"
          :key="item.id"
          :label="item.name"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form-item>
  </el-form>
    </el-header>
    <el-table
      :data="tableData"
      stripe
      style="width: 100%">
      <el-table-column
        prop="id"
        type="selection"
        label="序号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="orderno"
        label="订单id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="fwmcname"
        label="服务名称">
      </el-table-column>
      <el-table-column
        prop="price"
        label="服务价格">
      </el-table-column>
      <el-table-column
        prop="fwfname"
        label="服务方">
      </el-table-column>
      <el-table-column
        prop="yysname"
        label="运营商">
      </el-table-column>
      <el-table-column
        prop="areaname"
        label="服务区">
      </el-table-column>
      <el-table-column
        prop="status"
        label="订单状态">
      </el-table-column>
      <el-table-column
      prop="createdTime"
      label="创建时间">
      </el-table-column>
    </el-table>
    <el-footer>
      <el-footer>
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="search.page"
            :page-size="search.pageSize"
            layout="total, prev, pager, next"
            :total="search.total">
          </el-pagination>
        </div>
      </el-footer>
    </el-footer>
  </el-container>
  </template>
<script>
export default {
  name: 'OrderListView',
  data () {
    return {
      tableData: [],
      dics: [],
      // 保存分页以及查询的关键字
      search: {
        page: 1,
        pageSize: 5,
        key: '',
        total: 0
      },
      form: {
        area: {
          areaname: '',
          areaId: 0,
          providerid: 0,
          serviceId: 0,
          operationId: 0,
          clitel: 0
        }
      }
    }
  },
  /**
       * 计算字段
       */
  computed: {
    // 服务名称
    dicServices () {
      return this.dics.filter(x => {
        return x.type === 1
      })
    },
    dicOperations () {
      return this.dics.filter(x => {
        return x.type === 2
      })
    },
    dicProviders () {
      return this.dics.filter(x => {
        return x.type === 3
      })
    }
  },
  methods: {
    onSubmit () {

    },
    handleSizeChange (val) {
      this.search.pageSize = val
      this.query()
    },
    handleCurrentChange (val) {
      this.search.page = val
      this.query()
    },
    /**
         * 保存下拉框
         * @param val
         */
    save () {
      this.axios.post('/order/save', this.form).then(res => {
        if (res.data.code === 200) {
          this.$message('保存成功')
        }
      })
    },
    query () {
      this.axios.get('/order/listOrderv').then(res => {
        this.tableData = res.data.records // 查询所有数据
        this.search.pageSize = res.data.size
        this.search.total = res.data.total
        this.search.page = res.data.current
      })
    }
  },
  created () {
    this.axios.get('/dic/list4').then(res => {
      this.dics = res.data
    })
    this.query()
  }

}
</script>
